/**
 * Generate code from /{{projectName}}-core/src/main/java/{{packageName}}/core/{{modules}}/domain/{{entities@SQL}}.java.hbs
 */
package cn.ibizlab.core.oauth2.domain;

import java.util.*;
import cn.ibizlab.util.domain.IEntity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.util.*;
import org.springframework.data.annotation.*;
import cn.ibizlab.util.annotation.*;
import cn.ibizlab.util.enums.*;
import cn.ibizlab.util.domain.EntityMP;
import java.io.Serializable;
import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.*;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import cn.ibizlab.core.oauth2.domain.OauthAccessToken;

/**
 * oauth客户端信息实体类[OauthClientDetails]
 *
 * @author generator
 */
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@TableName(value = "oauth_client_details", resultMap = "OauthClientDetailsResultMap")
@ApiModel(value = "OAUTH_CLIENT_DETAILS", description = "oauth客户端信息")
public class OauthClientDetails extends EntityMP implements Serializable
{

    /**
     * 标识
     */
    @Id
    @TableId(value = "client_id" , type = IdType.ASSIGN_UUID)
    @DEField(name = "client_id" , isKeyField = true)
    @JsonProperty("client_id")
    @JSONField(name = "client_id")
    @ApiModelProperty(value = "client_id", notes = "标识")
    private String clientId;

    /**
     * 名称
     */
    @TableField(value = "client_name")
    @DEField(name = "client_name")
    @JsonProperty("client_name")
    @JSONField(name = "client_name")
    @ApiModelProperty(value = "client_name", notes = "名称")
    private String clientName;

    /**
     * 资源id集合
     */
    @TableField(value = "resource_ids")
    @DEField(name = "resource_ids")
    @JsonProperty("resource_ids")
    @JSONField(name = "resource_ids")
    @ApiModelProperty(value = "resource_ids", notes = "资源id集合")
    private String resourceIds;

    /**
     * 访问密钥
     */
    @TableField(value = "client_secret")
    @DEField(name = "client_secret")
    @JsonProperty("client_secret")
    @JSONField(name = "client_secret")
    @ApiModelProperty(value = "client_secret", notes = "访问密钥")
    private String clientSecret;

    /**
     * 权限范围
     */
    @TableField(value = "scope")
    @DEField(name = "scope" , dict = "Oauth2_grant_scope")
    @JsonProperty("scope")
    @JSONField(name = "scope")
    @ApiModelProperty(value = "scope", notes = "权限范围")
    private String scope;

    /**
     * 支持的授权类型
     */
    @TableField(value = "authorized_grant_types")
    @DEField(name = "authorized_grant_types" , dict = "Oauth2_grant_types")
    @JsonProperty("authorized_grant_types")
    @JSONField(name = "authorized_grant_types")
    @ApiModelProperty(value = "authorized_grant_types", notes = "支持的授权类型")
    private String authorizedGrantTypes;

    /**
     * 客户端重定向URI
     */
    @TableField(value = "web_server_redirect_uri")
    @DEField(name = "web_server_redirect_uri")
    @JsonProperty("web_server_redirect_uri")
    @JSONField(name = "web_server_redirect_uri")
    @ApiModelProperty(value = "web_server_redirect_uri", notes = "客户端重定向URI")
    private String webServerRedirectUri;

    /**
     * authorities
     */
    @TableField(value = "authorities")
    @DEField(name = "authorities")
    @JsonProperty("authorities")
    @JSONField(name = "authorities")
    @ApiModelProperty(value = "authorities", notes = "authorities")
    private String authorities;

    /**
     * access_token_validity
     */
    @TableField(value = "access_token_validity")
    @DEField(name = "access_token_validity")
    @JsonProperty("access_token_validity")
    @JSONField(name = "access_token_validity")
    @ApiModelProperty(value = "access_token_validity", notes = "access_token_validity")
    private Integer accessTokenValidity;

    /**
     * refresh_token_validity
     */
    @TableField(value = "refresh_token_validity")
    @DEField(name = "refresh_token_validity")
    @JsonProperty("refresh_token_validity")
    @JSONField(name = "refresh_token_validity")
    @ApiModelProperty(value = "refresh_token_validity", notes = "refresh_token_validity")
    private Integer refreshTokenValidity;

    /**
     * 其他信息
     */
    @TableField(value = "additional_information")
    @DEField(name = "additional_information")
    @JsonProperty("additional_information")
    @JSONField(name = "additional_information")
    @ApiModelProperty(value = "additional_information", notes = "其他信息")
    private String additionalInformation;

    /**
     * 自动批准授予权限
     */
    @TableField(value = "autoapprove")
    @DEField(name = "autoapprove" , dict = "Oauth2_grant_scope")
    @JsonProperty("autoapprove")
    @JSONField(name = "autoapprove")
    @ApiModelProperty(value = "autoapprove", notes = "自动批准授予权限")
    private String autoapprove;

    /**
     * 创建时间
     */
    @TableField(value = "create_time" , fill = FieldFill.INSERT)
    @DEField(name = "create_time" , preType = DEPredefinedFieldType.CREATEDATE)
    @JsonProperty("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JSONField(name = "create_time" , format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "create_time", notes = "创建时间")
    private Date createTime;

    /**
     * DC
     */
    @TableField(value = "dc")
    @DEField(name = "dc")
    @JsonProperty("dc")
    @JSONField(name = "dc")
    @ApiModelProperty(value = "dc", notes = "DC")
    private String dc;

    /**
     * 设置 [名称]
     */
    public OauthClientDetails setClientName(String clientName) {
        this.clientName = clientName;
        this.modify("client_name", clientName);
        return this;
    }

    /**
     * 设置 [资源id集合]
     */
    public OauthClientDetails setResourceIds(String resourceIds) {
        this.resourceIds = resourceIds;
        this.modify("resource_ids", resourceIds);
        return this;
    }

    /**
     * 设置 [访问密钥]
     */
    public OauthClientDetails setClientSecret(String clientSecret) {
        this.clientSecret = clientSecret;
        this.modify("client_secret", clientSecret);
        return this;
    }

    /**
     * 设置 [权限范围]
     */
    public OauthClientDetails setScope(String scope) {
        this.scope = scope;
        this.modify("scope", scope);
        return this;
    }

    /**
     * 设置 [支持的授权类型]
     */
    public OauthClientDetails setAuthorizedGrantTypes(String authorizedGrantTypes) {
        this.authorizedGrantTypes = authorizedGrantTypes;
        this.modify("authorized_grant_types", authorizedGrantTypes);
        return this;
    }

    /**
     * 设置 [客户端重定向URI]
     */
    public OauthClientDetails setWebServerRedirectUri(String webServerRedirectUri) {
        this.webServerRedirectUri = webServerRedirectUri;
        this.modify("web_server_redirect_uri", webServerRedirectUri);
        return this;
    }

    /**
     * 设置 [authorities]
     */
    public OauthClientDetails setAuthorities(String authorities) {
        this.authorities = authorities;
        this.modify("authorities", authorities);
        return this;
    }

    /**
     * 设置 [access_token_validity]
     */
    public OauthClientDetails setAccessTokenValidity(Integer accessTokenValidity) {
        this.accessTokenValidity = accessTokenValidity;
        this.modify("access_token_validity", accessTokenValidity);
        return this;
    }

    /**
     * 设置 [refresh_token_validity]
     */
    public OauthClientDetails setRefreshTokenValidity(Integer refreshTokenValidity) {
        this.refreshTokenValidity = refreshTokenValidity;
        this.modify("refresh_token_validity", refreshTokenValidity);
        return this;
    }

    /**
     * 设置 [其他信息]
     */
    public OauthClientDetails setAdditionalInformation(String additionalInformation) {
        this.additionalInformation = additionalInformation;
        this.modify("additional_information", additionalInformation);
        return this;
    }

    /**
     * 设置 [自动批准授予权限]
     */
    public OauthClientDetails setAutoapprove(String autoapprove) {
        this.autoapprove = autoapprove;
        this.modify("autoapprove", autoapprove);
        return this;
    }

    /**
     * 设置 [DC]
     */
    public OauthClientDetails setDc(String dc) {
        this.dc = dc;
        this.modify("dc", dc);
        return this;
    }

    /**
     * 复制当前对象数据到目标对象(粘贴重置)
     * @param targetEntity 目标数据对象
     * @param includeEmpty  是否包括空值
     * @param <T>
     * @return
     */
    @Override
    public <T> T pasteTo(T targetEntity, boolean includeEmpty) {
        super.pasteTo(targetEntity, includeEmpty);
        if(targetEntity instanceof IEntity) {
            IEntity entity = ((IEntity) targetEntity);
            entity.reset("client_id");
        }
        return targetEntity;
    }

}